<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>规则引擎管理</title>
   <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript" src="/js/petecat.js"></script>
    <script type="text/javascript" src="/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/extvalid.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/main.css"></link>
    <link rel="stylesheet" type="text/css" href="/css/themes/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="/css/themes/icon.css"></link>
	<link rel="stylesheet" type="text/css" href="/css/themes/color.css"></link>
    
</head>
<body>
 <table id="wxConfigManage"  toolbar='#northPanel'>
</table>
 <div id="northPanel" class="dg-toolbar-div">
	 <table class="queryTb">
	  <tr>
	    <td align="right">名称：</td><td><input type="text" id="queryName"  class="textbox sys_defult_textbox"/></td>
	 </tr>
	 </table>
	<div  align="center"> 
	 <a id="btnQuery"  onclick="queryDg()" href="javascript:void(0)" style="width:80px" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
	 <a id="restBtnQuery" onclick="resetDg()"  href="javascript:void(0)"  style="width:80px" class="easyui-linkbutton" data-options="iconCls:'icon-redo'">重置</a>
	 <span  power="ADDRULE">
	     <a id="btnAdd" href="javascript:void(0)"  style="width:80px" class="easyui-linkbutton" data-options="iconCls:'icon-add'">新增</a>
	 </span>
   </div>
 </div>
<div id="win"></div>
<script type="text/javascript">
    //检查权限
    checkPowerAndJump("QRYRULE");
    $(function(){
    	$("#wxConfigManage").datagrid({
    			  pagination:true,
    			  url:BUS_URL+"test/queryTestByPage",
    			  loadMsg:'加载中...',
   			      beforeSend: function(request) {
   			    	 request.setRequestHeader('Authorization',getSessionData('userToken'));
                  },
                  method:'get',
    			  singleSelect:true,
    			  fitColumns:true,
    			  striped:true,
    			  border:false,
    			  fit:true,
    			  columns:[[   
    	                     {title:'名称',field:'fieldname',width:100},
    			             {title:'操作',field:'operate',width:80,
    			              formatter: function(value,row,index){
    			 				 var str = "";
    			            	  if(checkPower("QRYRULE")){
    			            		  str+= '<a href="javascript:qry(\''+row.refcode+'\')">查看</a><span class="btnSplit"></span>';
    			            	  }
    			            	  if(checkPower("MODRULE")){
    			            		  str+= '<a href="javascript:mod(\''+row.refcode+'\')">修改</a><span class="btnSplit"></span>';
    			            	  }
    			            	  if(checkPower("DELRULE")){
    			            		  str+= '<a href="javascript:del(\''+row.refcode+'\')">删除</a><span class="btnSplit"></span>';
    			            	  }
    			 				return str;  
    						}}
    			 ]] 
    		});

    	$("#btnAdd").click(function(){
    		if(!win_show_flag){
    			initWin();
    			win_show_flag = true;
    		}
    		$('#win').window('setTitle','新增配置');
    		$('#win').window('open');
    		$('#win').window('refresh', "ruleadd.html");
    	})
    })
    
var win_show_flag = false;   
var op_refcode="";
function initWin(){
	$('#win').window({
		width:800,
		height:330,
		collapsible : false,
		minimizable : false,
		maximizable:false,
		resizable:false,
		closed:true,
		modal:true
	})
}

//修改
function mod(refcode){
	console.dir($("#wxConfigManage").datagrid('getData'));
	op_refcode = refcode;
	if(!win_show_flag){
		initWin();
		win_show_flag = true;
	}
	$('#win').window('setTitle','修改配置');
	$('#win').window('open');
	$('#win').window('refresh', 'rulemod.html');
}

//删除
function del(refcode){
	op_refcode = refcode;
	if(!win_show_flag){
		initWin();
		win_show_flag = true;
	}
	$('#win').window('setTitle','删除配置');
	$('#win').window('open');
	$('#win').window('refresh', 'ruledel.html');
}

function qry(refcode){
	op_refcode = refcode;
	if(!win_show_flag){
		initWin();
		win_show_flag = true;
	}
	$('#win').window('setTitle','查看配置');
	$('#win').window('open');
	$('#win').window('refresh', 'ruleqry.html');

}


function queryDg(){
	 $("#wxConfigManage").datagrid("options").queryParams={
		 fieldname:$.trim($("#queryName").val())
  	 };
  	 $("#wxConfigManage").datagrid("load");
}

function resetDg(){
	 $("#queryName").val('');
	 $("#wxConfigManage").datagrid("options").queryParams={
  	 };
  	 $("#wxConfigManage").datagrid("load");
}
</script>
</body>
</html>